001 /*
002 * Copyright 2005 Stephen J. McConnell.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
013 * implied.
014 *
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019 package net.dpml.transit.info;
020
021 import java.net.URI;
022
023 import net.dpml.lang.ValueDirective;
024
025 /**
026 * The CodeBaseDirective is immutable datastructure used to
027 * describe a codebase.
028 *
029 * @author <a href="http://www.dpml.net">Digital Product Meta Library</a>
030 * @version 1.0.1
031 */
032 public class LayoutDirective extends CodeBaseDirective
033 {
034 private final String m_id;
035 private final String m_title;
036
037 /**
038 * Creation of a new codebase descriptor.
039 * @param id the datatype identifier
040 * @param title the handler title
041 * @param codebase the codebase uri
042 * @param parameters an array of plugin parameter descriptors
043 * @exception NullPointerException if the id is null
044 */
045 public LayoutDirective(
046 String id, String title, URI codebase, ValueDirective[] parameters )
047 throws NullPointerException
048 {
049 super( codebase, parameters );
050 if( null == id )
051 {
052 throw new NullPointerException( "id" );
053 }
054 m_id = id;
055 if( null == title )
056 {
057 m_title = id;
058 }
059 else
060 {
061 m_title = title;
062 }
063 }
064
065 /**
066 * Return the unique content handler datatype identifier.
067 *
068 * @return the handler id
069 */
070 public String getID()
071 {
072 return m_id;
073 }
074
075 /**
076 * Return the content handler title.
077 *
078 * @return the title
079 */
080 public String getTitle()
081 {
082 return m_title;
083 }
084
085 /**
086 * Test if the supplied object is equal to this object.
087 * @param other the object to evaluate
088 * @return true if this object is equal to the supplied object
089 */
090 public boolean equals( Object other )
091 {
092 if( super.equals( other ) && ( other instanceof LayoutDirective ) )
093 {
094 LayoutDirective directive = (LayoutDirective) other;
095 if( !equals( m_id, directive.m_id ) )
096 {
097 return false;
098 }
099 else
100 {
101 return equals( m_title, directive.m_title );
102 }
103 }
104 else
105 {
106 return false;
107 }
108 }
109
110 /**
111 * Compute the instance hashcode value.
112 * @return the hashcode
113 */
114 public int hashCode()
115 {
116 int hash = super.hashCode();
117 hash ^= hashValue( m_id );
118 hash ^= hashValue( m_title );
119 return hash;
120 }
121 }